package com.Web.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/Insert")
public class Insert extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
            // 设置请求参数编码
            req.setCharacterEncoding("UTF-8");
            // 设置响应数据编码
            resp.setCharacterEncoding("UTF-8");
            // 获取请求参数
            String id = req.getParameter("id");
            String name = req.getParameter("name");
            String age = req.getParameter("age");
            String cellphone = req.getParameter("cellphone");
            String address = req.getParameter("address");
            String gender = req.getParameter("gender");
            //通过响应数据流，向浏览器发送数据
            JDBCUtils.update("insert into student(name,age,cellphone,address,gender) values(?,?,?,?,?)",name,age,cellphone,address,gender);

    }
}
